document.getElementById('videoPlayer').addEventListener('error', function(e) {
    console.error('Video error:', e);
});
function uploadVideo() {
    const videoInput = document.getElementById('videoInput');
    const file = videoInput.files[0];

    if (file) {
        const formData = new FormData();
        formData.append('video', file);

        fetch('/upload', { // 后端上传接口
            method: 'POST',
            body: formData,
        })
            .then(response => response.json())
            .then(data => {
                console.log('Video uploaded successfully');
                const videoPlayer = document.getElementById('videoPlayer');
                videoPlayer.src = data.videoUrl; // 确保这里使用的是正确的视频URL
                videoPlayer.load(); // 重新加载视频
            })
            .catch(error => {
                console.error('Error uploading video:', error);
            });
    } else {
        alert('Please select a video file.');
    }
}
